package com.iweb.manager.controller;


import com.iweb.manager.model.shows;
import com.iweb.manager.service.ShowsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/shows")
public class ShowsController {

    @Autowired
    private ShowsService showsService;

    @GetMapping
    public List<shows> selectAllShows() {
        return showsService.selectAllShows();
    }

    @GetMapping("/selectOne")
    public shows selectOneShow(@RequestParam int show_id) {
        return showsService.selectOneShow(show_id);
    }

    @PostMapping
    public String addOneShow(@ModelAttribute shows show) {
        return showsService.addOneShow(show)>0?"添加成功":"添加失败";
    }

    @DeleteMapping
    public String deleteOneShow(@RequestParam  int show_id) {
        return showsService.deleteOneShow(show_id)>0?"删除成功":"删除失败";
    }

    @PutMapping
    public String updateOneShow(@ModelAttribute shows show) {
        return showsService.updateOneShow(show)>0?"修改成功":"修改失败";
    }


}
